﻿// modified by Vincenzo Panza
// last data:24/10/10
using System;
using System.Diagnostics;
using System.Threading;
using mAdcOW.DataStructures;
using mAdcOW.DataStructures.DictionaryBacking;

namespace BenchmarkConsoleApp
{
	internal class Program
	{
		public class MemoryMappedArrayTest
		{
			static string path = AppDomain.CurrentDomain.BaseDirectory;
			static mAdcOW.DataStructures.List<int> al = new mAdcOW.DataStructures.List<int>(100000, path);
			static System.Collections.Generic.List<int> al_ = new System.Collections.Generic.List<int>();
			static int j=0;
			static Random rnd = new Random();
			
			[Benchmark]
			public static void TestInsert_Ideal()
			{
				for (int i=0; i < 100000; i++)
					al_.Add(rnd.Next());
			}

			[Benchmark]
			public static void TestInsert_MMF()
			{
				for (int i=0; i < 100000; i++)
					al.Add(rnd.Next());
			}

			[Benchmark]
			public static void TestExist_Ideal()
			{
				for (int i=0; i < 1000; i++)
					al_.Contains(i);
			}

			[Benchmark]
			public static void TestExist_MMF()
			{
				for (int i=0; i < 1000; i++)
					al.Contains(i);
			}

			[Benchmark]
			public static void TestFetch_Ideal()
			{
				for (int i=0; i < 100000; i++)
					j=al_[i];
			}

			[Benchmark]
			public static void TestFetch_MMF()
			{
				for (int i=0; i < 100000; i++)
					j=al[i];
			}
			
			[Benchmark]
			public static void TestRemoveAt_Ideal()
			{
				for (int i=0; i < 1000; i++)
					al_.RemoveAt(i);
			}
			
			[Benchmark]
			public static void TestRemoveAt_MMF()
			{
				for (int i=0; i < 1000; i++)
					al.RemoveAt(i);
			}
		}
	}
}